﻿package ua.mihaylenko.app 
{
	import flash.display.Sprite;
	import flash.events.Event;
	import ua.mihaylenko.app.controller.APPStage;
	import ua.mihaylenko.app.data.AppData;
	import ua.mihaylenko.app.ui.preloader.UIPreloader;
	import ua.mihaylenko.app.ui.window.UIWindow;
	/**
	 * ...
	 * @author Mihaylenko A.L.
	 */
	public class AppMain extends Sprite
	{
		private var _cPreloader:UIPreloader;
		public function AppMain()
		{
			if (stage)innit();
				else addEventListener(Event.ADDED_TO_STAGE , innit);
		}
		/**
		 * 
		 * @param	...arguments
		 * [0] - $align(Show and hide parameter align)::int - public constants align in this class
		 * [1] - $timeShow(Time for show window)::int - frames
		 * [2] - $timeHide(Time for hide window)::int - frames
		 * [3] - $container(DisplayObjectContainer) for added this disp instance to display list
		 * [4] - $maxBlur - max blur in show and hide effect
		 */		
		private function innit(e:Event=null):void 
		{
			removeEventListener(Event.ADDED_TO_STAGE, innit);
			APPStage.appStage = this;
			AppData.instance.addEventListener(Event.COMPLETE, onDataLoaded);
			AppData.instance.innit();
		}
		
		private function onDataLoaded(e:Event):void 
		{
			AppData.instance.removeEventListener(Event.COMPLETE, onDataLoaded);
		}
		
	}

}